package com.ruoyi.common.result;

import lombok.Data;

@Data
public class dataResult {
    private int code; //编码 200/400
    private String msg; //成功/失败
    private Long total;//总记录数
    private Object data;//数据

    public static dataResult fail(){
        return dataresult(400,"失败",0L,null);
    }

    public static dataResult suc(){
        return dataresult(200,"成功",0L,null);
    }

    public static dataResult suc(Object data){
        return dataresult(200,"成功",0L,data);
    }

    public static dataResult suc(Object data, Long total){
        return dataresult(200,"成功",total,data);
    }

    private static dataResult dataresult(int code, String msg, Long total, Object data) {
        dataResult res=new dataResult();
        res.setCode(code);
        res.setMsg(msg);
        res.setTotal(total);
        res.setData(data);
        return res;
    }
}
